package JavaSe.IO;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName interview
 * @Description: TODO
 * @date ${DAT}14:49
 */
public class FileInputOutputStreamTest {
    public static void main(String[] args) {
        FileInputStream inputStream = null;


        // 造流
        try {
            File file1 = new File("test1.txt");
            inputStream = new FileInputStream(file1);


            // 读数据
            byte[] buffer = new byte[5];
            int len; // 记录每次读取的字节的个数
            while ((len = inputStream.read(buffer)) != -1) {
                String str = new String(buffer,0,len);
                System.out.print(str);
            }
        }catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
